package com.beater.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.beater.controller.bean.ResponseBodyJson;

/**
 * 全局异常处理
 * @author 罗涛
 *
 */

@ControllerAdvice(basePackages = "com.beater.exception")
public class GlobalException {
	@ExceptionHandler(RuntimeException.class)
	@ResponseBody
	public ResponseBodyJson exception(Exception e) {
		if (e instanceof BusinessException) {
			return ResponseBodyJson.createErrorResBody(((BusinessException)e).getExMsg(),((BusinessException)e).getExCode());
		}
		return ResponseBodyJson.createErrorResBody("") ;
	}

}
